package top.aicats.redis.pubsub;

import redis.clients.jedis.Jedis;

public class ListenerTest {
    public static void main(String[] args)  {
        final Jedis jedis = new Jedis("192.168.1.120", 6379);
        final MyListener listener = new MyListener();
        jedis.psubscribe(listener, new String[]{"james*"});

        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(6*1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                listener.punsubscribe(new String[] {"james*"});
                jedis.close();
                System.out.println("----------------运行完了------------");
            }
        }).start();
    }
}
